package iss.java.list;
import java.util.concurrent.locks.ReadWriteLock;  
/**
 * Created by wenke on 2016/9/16.
 * TODO: Modify this class to meet requirement A and C.
 */
public class Node {
    private int data;
    private Node prev;
    private Node next;
    private ReadWriteLock lock;
    public Node(ReadWriteLock l) {
    	lock = l;
    }
    
    public int getData() {
    	lock.readLock().lock();
    	try {
    		return data;
    	} finally {
    		lock.readLock().unlock();
    	}
    }

    public Node setData(int data) {
        this.data = data;
        return this;
    }

    public Node getPrev() {
    	lock.readLock().lock();
    	try {
    		return prev;
    	} finally {
    		lock.readLock().unlock();
    	}
    }

    Node setPrev(Node prev) {
        this.prev = prev;
        return this;
    }

    public Node getNext() {
    	lock.readLock().lock();
    	try {
    		return next;
    	} finally {
    		lock.readLock().unlock();
    	}
    }

    Node setNext(Node next) {
        this.next = next;
        return this;
    }
    
    ReadWriteLock getLock() {
    	return lock;
    }
}
